const { runExecutablesInParallel, sendMultipleSocketRequests } = require('../../../common')
const path = require('path')
const { basePath } = require('../../../config');
const { error } = require('console');


let data = [
    {
        "port": 8888,
        "message": { "task_name": "task", "args": "111" }
    },
    {
        "port": 8888,

        "message": { "task_name": "tiktok", "args": "222" }
    },
    {
        "port": 8888,
        "message": { "task_name": "init_chrome_driver" }
    }
]

async function asyncMessage(event, arg) {
    console.log('Received async message from Vue:', arg);
    // runExecutablesInParallel(data).then(results => {
    //     console.log(results)
    //     event.sender.send('vue-async-reply', results);
    // }).catch(error => {
    //     console.error('Failed to get results:', error)
    // });
    message = await sendMultipleSocketRequests(data).catch(error => {
        console.error('Failed to get results:', error)
    })
    event.sender.send('vue-async-reply', message);
    console.log(message)
}

module.exports = {
    asyncMessage
}